﻿using MyWpf.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWpf.ViewModel
{
	public class MainWindowViewModel : NotificationObject
	{

		private string num1;

		public int Num1
		{
			get { return int.TryParse(num1,out var n1)?n1:0; }
			set 
			{ 
				num1 = value.ToString(); 
				this.RaisePropertyChanged(nameof(Num1));
			}
		}
		private string num2;

		public int Num2
		{
			get { return int.TryParse(num2, out var n2) ? n2 : 0; }
			set
			{
				num2 = value.ToString();
				this.RaisePropertyChanged(nameof(Num2));
			}
		}

		private string num3;

		public int Num3
		{
			get { return int.TryParse(num3, out var n3) ? n3 : 0; }
			set
			{
				num3 = value.ToString();
				this.RaisePropertyChanged(nameof(Num3));
			}
		}

		public DelegateCommand AddCommand { get; set; }
		public void Add(Object paramter)
		{
            this.Num3 = this.Num1 + this.Num2;
		}
		
        public MainWindowViewModel()
        {

			this.AddCommand = new DelegateCommand();
			this.AddCommand.ExecuteAction = new Action<object>(this.Add);
        }

    }
}
